<?php
/**
 * QQAS - share your knowledge to the world!
 *
 * @author		xiaochong0302 <xiaochong0302@gmail.com>
 * @copyright	Copyright (c) 2011, Koogua Studio.
 * @license		http://www.qqas.org/user_guide/license.html
 * @link		http://www.qqas.org
 * @since		Version 1.0
 * @filesource
 */


class TagModel extends Model
{

    /**
     * 获取Tag
     *
     * @param integer $tagID
     * @return array
     */
	public function getTagByID($tagID)
	{
		$where['tag_id'] = intval($tagID);
		return $this->where($where)->find();
	}

    /**
     * 获取Tag
     *
     * @param string $name
     * @return array
     */
	public function getTagByName($name)
	{
		$where['name'] = trim($name);
		return $this->where($where)->find();
	}


    /**
     * 开放Tag
     *
     * @param array $tagID
     * @return null
     */
	public function openTagByID($tagID)
	{
		$where['tag_id'] = array('in', $tagID);
		$data['status'] = 1;
		$this->where($where)->save($data);
	}


    /**
     * 锁定Tag
     *
     * @param array $tagID
     * @return null
     */
	public function lockTagByID($tagID)
	{
		$where['tag_id'] = array('in', $tagID);
		$data['status'] = 0;
		$this->where($where)->save($data);
	}


    /**
     * 删除Tag
     *
     * @param array $tagID
     * @return null
     */
	public function deleteTagByID($tagID)
	{
		$Model = M('QuestionTag');
		$where['tag_id'] = array('in', $tagID);
		$Model->where($where)->delete();
		$this->where($where)->delete();
	}

}

/* End of file TagModel.class.php */
/* Location: ./App/Lib/Model/TagModel.class.php */